package com.test.exoplayertest;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.FrameLayout;

import com.test.exoplayertest.player.BaseVideoActivity;

public class MainActivity extends BaseVideoActivity {
    //直播流
    String url_live = "http://abclive.abcnews.com/i/abc_live4@136330/index_1200_av-b.m3u8?sd=10&b=1200&rebase=on";

    //  点播流
    String url_video_mpd = "http://www.youtube.com/api/manifest/dash/id/bf5bb2419360daf1/source/youtube?as=fmp4_audio_clear,fmp4_sd_hd_clear&sparams=ip,ipbits,expire,source,id,as&ip=0.0.0.0&ipbits=0&expire=19000000000&signature=51AF5F39AB0CEC3E5497CD9C900EBFEAECCCB5C7.8506521BFC350652163895D4C26DEE124209AA9E&key=ik0";
    String url_video_mp4 = "http://file.xjkb.com/group1/M00/00/1A/eEzdEFh8Z-mAQdc6AcR3DvBgTPU994.mp4";
    String url_video_flv = "http://112.253.22.157/17/z/z/y/u/zzyuasjwufnqerzvyxgkuigrkcatxr/hc.yinyuetai.com/D046015255134077DDB3ACA0D7E68D45.flv";

    String url_video_m3u8 = "http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8";
    //path = "http://www.modrails.com/videos/passenger_nginx.mov";

    FrameLayout player_content, player_content2;
    private boolean isOne = true;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        player_content = (FrameLayout) findViewById(R.id.player_content);
        player_content2 = (FrameLayout) findViewById(R.id.player_content_2);
        attach(player_content);
        adJustPlayerLayout(false);
//        startPlay(url_video_mpd, "mpd");
        startPlay(url_video_flv, "flv");
    }

    public void changePosition(View view) {
        FrameLayout newLayout;
        if (isOne) {
            newLayout = player_content2;
        } else {
            newLayout = player_content;
        }
        detach();
        attach(newLayout);
        isOne = !isOne;
    }

    public void clickLive(View view) {
        startPlay(url_live, "m3u8");
    }

    public void clickVideo(View view) {
        startPlay(url_video_mpd, "mpd");
    }

    public void next(View view) {
        Intent intent = new Intent(this, TestActivity1.class);
        startActivity(intent);
    }

    @Override
    public void beforeConfigurationChanged(boolean isLand) {
        if (!isOne) {
            detach();
            if (isLand) {
                attach(player_content);
            } else {
                adJustPlayerLayout(isLand);
                attach(player_content2);
            }
        }
    }
}
